package cn.lkx.eduservice.controller.front;

import cn.lkx.commonutils.R;
import cn.lkx.eduservice.entity.EduCourse;
import cn.lkx.eduservice.entity.EduTeacher;
import cn.lkx.eduservice.service.front.IndexFrontService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 前台首页 控制器
 */
@RestController
@RequestMapping("/eduservice/frontindex")
@CrossOrigin
public class IndexFrontController {

    @Autowired
    IndexFrontService indexFrontService;

    //获取前台首页的 课程和讲师 进行展示
    @GetMapping("indexCourseAndTeacher")
    public R getCourseAndTeacher(){
        //查询排名前8的课程
        List<EduCourse> indexCourse = indexFrontService.getIndexCourse();
        //查询前4的讲师
        List<EduTeacher> indexTeacher = indexFrontService.getIndexTeacher();
        return R.ok().data("courseList",indexCourse).data("teacherList",indexTeacher);
    }

}
